package src.com.java.dtgh.oneDay;

public class demo1 {

    public static void main(String[] args) {

        demo1 demo1 = new demo1();
        demo1.uniquePaths(3,7);
    }

    public int uniquePaths(int m, int n) {

        int[][] dp = new int[m][n];
        solution(dp);
//        printArray(dp);

        return dp[m - 1][n - 1];
    }

    public void solution(int[][] dp){


        for(int i = 0; i < dp.length; i++){
            for(int j = 0; j < dp[0].length; j++){

                if(i == 0 && j == 0){
                    dp[i][j] = 0;
                }
                if(i == 0 || j == 0) {
                    dp[i][j] = 1;
                }else {
                    dp[i][j] = dp[i-1][j] + dp[i][j-1];
                }

            }
        }

    }
    public void printArray(int[][] arr){
        for(int i = 0; i < arr.length; i++){
            for(int j = 0; j < arr[0].length; j++){
                System.out.print(arr[i][j] + " ");
            }
            System.out.println();
        }
    }
}
